import { defineStore } from "pinia";
import pinia from ".";
import { isEmpty } from "@/utils"

export enum LoadStatus {
  init,
  load,
  success,
  fail
}
export default defineStore('OverallSituation', {
  state(){
    return {
      /** 加载状态 */
      loadStatus: LoadStatus.init,
      /** 文件访问前缀 */
      fileAccessPrefix: '',
    }
  },
  actions: {
    getFileUrl(path?: string){
      if(isEmpty(path)) return ''
      // #ifdef APP-PLUS
      if (path.startsWith('/static')) return path
      // #endif
      return path.startsWith('http') ? path : this.fileAccessPrefix + path
    },
    async loadPublicData(){
      if (this.fileAccessPrefix) return 
      return Promise.all([

      ])
    },
    async loadGlobalData(){
      this.loadStatus = LoadStatus.load
      try {
        await this.loadPublicData()

        await Promise.all([
          
        ])
        this.loadStatus = LoadStatus.success
      } catch (error) {
        this.loadStatus = LoadStatus.fail
        throw error        
      }
    },
  },
})(pinia)